<template>
  <div class="calendar-container">
    <calendar ref="calendar" lunar :value="dateValue" @select="select"></calendar>
  </div>
</template>

<script>
import calendar from '../../components/calendar'
import moment from 'moment'

export default {
  components: {
    calendar
  },
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    value: {
      type: Date,
      default() {
        return new Date()
      }
    }
  },
  data() {
    return {
      data: {
        lunar: true //显示农历
      }
    }
  },
  computed: {
    dateValue() {
      const d = this.value
      return [d.getFullYear(), d.getMonth() + 1, d.getDate()]
    }
  },
  methods: {
    select(value) {
      const [year, month, day] = value
      console.log(value)
      this.$emit('input', moment([year, month - 1, day]).toDate())
      this.$emit('update:visible', false)
    }
  }
}
</script>

<style lang="scss" scoped>
.calendar-container {
  width: 100%;
  height: 100%;
  position: fixed;
  background: #f5f5f5;
  left: 0;
  top: 0;
}
</style>
